package com.prime.tutorial.moviestore.service.logicalview;

import com.prime.tutorial.moviestore.domain.*;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * Provides nice interface to Logical Inventory <br/>
 * Created by IntelliJ IDEA. <br/>
 * User: me <br/>
 * Date: 25 бер 2010 <br/>
 * Time: 23:25:25<br/>
 * @author iryna.masyuk
 */
public interface LogicalTest {
    /**
     * Returns countries where devices exist
     * @return   list of countries
     */
    public List getCountriesWithDevices();

    /**
     * Gets all cities in the country where devices exist
     * @param countryId
     * @return list of cities
     */
    public List getCitiesWithDevices(int countryId);

    /**
     * Returns core devices in the city
     * @param cityId id of the city
     * @return list of devices
     */
    public List<Device> getCoreDevices(int cityId);

    /**
     * Returns the children of the device
     * @param deviceId id of the device, whose children we're looking for
     * @return list of the devices
     */
    public List<Device> getChildDevices(int deviceId);
    /**
     * Returns models(i.e. Cisco Catalyst 2960 etc.) by modelType(i.e. switch, router etc.)
     * @param typeName
     * @return
     */
    public List<Model> getModelsByType(String typeName);

    /**
     * Returns ports by device
     * @param deviceId
     * @return list of ports
     */
     public List<Port> getPorts(int deviceId);
    /**
     * Persists new device with status PLANNED_INSTALLATION and with given parameters
     * @param deviceName   device name
     * @param typeName     name of the model
     * @param streetName   name of the street
     * @param buildingName name of the building
     * @param aprtName     name of the apartment
     * @param description  optional description of the device
     * @param countryName  name of the country
     * @param cityName     name of the city
     * @param x            x-coordinate of the device
     * @param y            y-coordinate of the device
     * @return             Device if success, null otherwise
     */
    @Transactional
    public Device addDevice(String deviceName,
                            String typeName,
                            String streetName,
                            String buildingName,
                            String aprtName,
                            String description,
                            String countryName,
                            String cityName,
                            double x,
                            double y);
   /**
     * Adds the connection between two ports
     * @param portIdFrom port of the parent device
     * @param portIdTo port of the child device
     * @return true if the connection is created, false otherwise
     */
    @Transactional
    public boolean addConnections(int portIdFrom, int portIdTo);

    /**
     * Gets the child connections of the device 
     * @param deviceId  id of the device
     * @return list of DeviceToDevice
     */
     public List<DeviceToDevice> getChildConnections(int deviceId);

    /**
     * Returns the deviceTypes by device id
     * @param deviceId
     * @return list of ModelType
     */
     public List<ModelType> getDeviceTypesByDeviceId(int deviceId);

   /**
     * Sets the new position of the device
     * @param deviceId id of the device
     * @param x        new x-coordinate
     * @param y        new x-coordinate
     * @return         true if success, false otherwise
     */
    @Transactional
    public boolean changeDevicePosition(int deviceId, double x, double y);

    /**
     * Changes the name of the device
     * @param deviceId id of the device
     * @param name     new name
     * @return         true if success, false otherwise
     */
    @Transactional
    public boolean changeDeviceName(int deviceId, String name);

    /**
     * Removes the device
     * @param deviceId id of the device to be removed
     * @return true if the device is removed, false otherwise
     */
    @Transactional
    public boolean deleteDevice(int deviceId);

    /**
     * Removes the connection between two ports
     * @param fromPortId port of the parent device
     * @param toPortId port of the child device
     * @return true if the connection is removed, false otherwise
     */
    @Transactional
    public boolean deleteConnection(int fromPortId, int toPortId);

    /**
     * Returns the list of models by type
     * @param deviceId
     * @param typeName
     * @return
     */
    public List<Model> getModelsByType(int deviceId, String typeName);
    //getters
    public List<DevicePort> getDevicePortByDevice(Device d);

    /**
     * Returns Country by country id
     * @param id id of the country
     * @return country
     */
    public Country getCountryById(Long id);

    /**
     * Returns Country by country name
     * @param name name of the country
     * @return
     */
    public Country getCountryByName(String name);

    /**
     * Returns Model by model name
     * @param modelName name of the model
     * @return Model
     */
    public Model getModelByName(String modelName);
}
